home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 712 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.8 KB

  1. From: clamage@Eng.Sun.COM (Steve Clamage)
  2. Message-ID: <4i8b8a$2tj@engnews1.Eng.Sun.COM>
  3. X-Original-Date: 14 Mar 1996 05:36:10 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 14 Mar 96 14:51:41 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: Anyone considered inheritable friendship?
  9. Organization: Sun Microsystems Inc., Mountain View, CA
  10. References: <4fnrfr$7b1@engnews1.Eng.Sun.COM> <AFwV3Hn027@qsar.chem.msu.su> <4i7qjr$gr7@mujibur.inmind.com>
  11. X-Newsreader: NN version 6.5.0 #21 (NOV)
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMUgyjeEDnX0m9pzZAQHeAgF+MBjafLSw1NCNUyli424+Riqvg6Evuo4/
  14.     f74ZqkYUONU9VfJgNAFEcdOgVXvF51a3
  15.     =pmnU
  16.  
  17. mfinney@inmind.com writes:
  18.  
  19. >In <AFwV3Hn027@qsar.chem.msu.su>, "Eugene Radchenko"
  20. ><eugene@qsar.chem.msu.su> writes:
  21. >>But it is not. Inheritable friendship is a natural extension of normal
  22. >>friendship (for tightly coupled classes) to tightly coupled hierarchies.
  23.  
  24. >Exactly.  And, not only have I considered, I have begged for it
  25. >on bended knee.  ...
  26.  
  27. >And it is NOT the same thing as making
  28. >the attributes public.  It is the same thing as making them
  29. >protected in another hierarchy.
  30.  
  31. Please notice that I did not say inherited friendship is the same
  32. as making the members public. I said the effect on program design
  33. and maintenance is the same.
  34.  
  35. If friendship is inherited, you cannot know what functions will
  36. depend on the details of the private parts of the class. You cannot
  37. know whether the unknown writers of these unknown functions will
  38. get right all the inter-relationships among the private parts.
  39. Since you don't know what programs will break if you make any changes
  40. to the private parts, and you have no assurance of the correctness of
  41. the use of these private members by unknown functions, you lose nothing
  42. by making them public. By making them public, you avoid the false
  43. sense of security which the "private" label seems to confer.
  44.  
  45. The point of making members private is that you have complete 
  46. knowledge of who has access to them. If you need or want to make a
  47. change, you know exactly who will be affected. If you allow friendship
  48. to be inherited, you lose that knowledge, and private status 
  49. provides no advantage.
  50.  
  51. Perhaps you can provide an example where inheritable friendship
  52. gives a distinct advantage over making the members public. Bear
  53. in mind that people you don't know about will be depending in
  54. ways you don't know about on the private details of the class.
  55. --
  56. Steve Clamage, stephen.clamage@eng.sun.com
  57. ---
  58. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  59. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  60. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  61. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  62. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  63.